package com.ocom.webapi.controller;

import com.ocom.common.constant.AccessServiceUrl;
import com.ocom.common.constant.HumanServiceUrl;
import com.ocom.common.constant.WebApiServiceUrl;
import com.ocom.common.resp.Result;
import com.ocom.common.utils.ResultUtil;
import com.ocom.common.utils.poi.ExcelUtil;
import com.ocom.common.vo.poi.AccessDevicePoi;
import com.ocom.common.vo.webapi.*;
import com.ocom.webapi.vo.ForecastDataVo;
import com.ocom.webapi.vo.staffpage.ImportVo;
import com.ocom.webapi.vo.studentpage.BoardersImportVo;
import com.ocom.webapi.vo.studentpage.DeptListVo;
import com.ocom.webapi.vo.studentpage.SImportVo;
import com.ocom.webapi.vo.studentpage.SubsidyDataVo;
import com.ocom.webapi.vo.xfpersonnel.XImportVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
public class TemplateController {

	/**
	 * 导入机器模板（AccessDevice/importDevice）
	 */
	@GetMapping(AccessServiceUrl.URL_AccessDeviceImportDeviceTemplate)
	public void importTemplate(HttpServletResponse response) throws IOException {
		ExcelUtil<AccessDevicePoi> util = new ExcelUtil<AccessDevicePoi>(AccessDevicePoi.class);
		util.importTemplateExcel(response, "门禁设备数据");
	}

	/**
	 * 导入人员模板（StaffPage/importTemplate）
	 */
	@GetMapping(WebApiServiceUrl.URL_StaffPageImportTemplate)
	public void StaffPageImportTemplate(HttpServletResponse response) throws IOException {
		ExcelUtil<ImportVo> util = new ExcelUtil<ImportVo>(ImportVo.class);
		util.importTemplateExcel(response, "人员数据");
	}

	/**
	 * 导入人员模板（StudentPage/importTemplate）
	 */
	@GetMapping(HumanServiceUrl.URL_StudentPageImportTemplate)
	public void StudentPageImportTemplate(HttpServletResponse response) throws IOException {
		ExcelUtil<SImportVo> util = new ExcelUtil<SImportVo>(SImportVo.class);
		util.importTemplateExcel(response, "人员数据");
	}

	/**
	 * 导入同住人员模板（StudentPage/boardersImportTemplate）
	 */
	@GetMapping(HumanServiceUrl.URL_StudentPageBoardersImportTemplate)
	public void StudentPageBoardersImportTemplate(HttpServletResponse response) throws IOException {
		ExcelUtil<BoardersImportVo> util = new ExcelUtil<BoardersImportVo>(BoardersImportVo.class);
		util.importTemplateExcel(response, "同住人员数据");
	}

	/**
	 * 导入消费人员模板（PersonnelPage/importTemplate）
	 */
	@GetMapping(HumanServiceUrl.URL_PersonnelPageImportTemplate)
	public void PersonnelPageImportTemplate(HttpServletResponse response) throws IOException {
		ExcelUtil<XImportVo> util = new ExcelUtil<XImportVo>(XImportVo.class);
		util.importTemplateExcel(response, "人员数据");
	}

	@GetMapping(HumanServiceUrl.URL_PersonnelPageImportTemplateB)
	public Result PersonnelPageImportTemplateB() {
		return ResultUtil.success("/webapi/xiamenyiyuan_importTemplate.xlsx");
	}


	/**
	 * 导入卡号（PersonnelPage/importTemplate）
	 */
	@GetMapping(WebApiServiceUrl.URL_ConsumeAccountCard)
	public void ConsumeAccountCardTemplate(HttpServletResponse response) throws IOException {
		ExcelUtil<ImportCardVo> util = new ExcelUtil<>(ImportCardVo.class);
		util.importTemplateExcel(response, "发卡信息");
	}


	/**
	 * 导入充值（RechargeImportTemplate）
	 */
	@GetMapping(WebApiServiceUrl.URL_RechargeImport)
	public void RechargeImportTemplate(HttpServletResponse response) throws IOException {
		ExcelUtil<ImportRechargeVo> util = new ExcelUtil<>(ImportRechargeVo.class);
		util.importTemplateExcel(response, "批量充值");
	}

	/**
	 * 4.11.2获取区域导入模板（areaAccessTemplate）
	 */
	@GetMapping(WebApiServiceUrl.URL_areaAccessTemplate)
	public void areaAccessTemplate(HttpServletResponse response) throws IOException {
		ExcelUtil<ImportAreaAccessVo> util = new ExcelUtil<>(ImportAreaAccessVo.class);
		util.importTemplateExcel(response, "区域权限");
	}

	@GetMapping(WebApiServiceUrl.URL_SubsidyDataTemplate)
	public void SubsidyDataTemplate(HttpServletResponse response) throws IOException {
		ExcelUtil<SubsidyDataVo> util = new ExcelUtil<>(SubsidyDataVo.class);
		util.importTemplateExcel(response, "补贴数据");
	}

	@GetMapping(WebApiServiceUrl.Url_DeptListTemplate)
	public void deptListTemplate(HttpServletResponse response) throws IOException {
		ExcelUtil<DeptListVo> util = new ExcelUtil<>(DeptListVo.class);
		util.importTemplateExcel(response, "部门导入模板");
	}

	/**
	 * 8.3.6获取缴费数据导入模板
	 *
	 * @param response
	 * @throws IOException
	 */
	@GetMapping(WebApiServiceUrl.Url_FeeDetailDataTemplate)
	public void feeDetailTemplate(HttpServletResponse response) throws IOException {
		ExcelUtil<FeeDetailExcelVo> util = new ExcelUtil<>(FeeDetailExcelVo.class);
		util.importTemplateExcel(response, "缴费数据导入模板");
	}

	//导入校园WIFI账号模板
	@GetMapping(WebApiServiceUrl.Url_SchoolWifiPageImportTemplate)
	public void schoolWifiPageImportTemplate(HttpServletResponse response) throws IOException {
		ExcelUtil<SchoolWifiPageVo> util = new ExcelUtil<>(SchoolWifiPageVo.class);
		util.importTemplateExcel(response, "校园WIFI账号模板");

	}


	//导入云电脑账号账号
	@GetMapping(WebApiServiceUrl.Url_CloudComputingPageImportTemplate)
	public void cloudComputingPageImportTemplate(HttpServletResponse response) throws IOException {
		ExcelUtil<CloudComputingPageVo> util = new ExcelUtil<>(CloudComputingPageVo.class);
		util.importTemplateExcel(response, "云电脑账号账号模板");

	}

	//导入校园手机号模板
	@GetMapping(WebApiServiceUrl.Url_SchoolPhonePageImportTemplate)
	public void schoolPhonePageImportTemplate(HttpServletResponse response) throws IOException {
		ExcelUtil<SchoolPhonePageVo> util = new ExcelUtil<>(SchoolPhonePageVo.class);
		util.importTemplateExcel(response, "校园手机号模板");

	}

	@GetMapping(WebApiServiceUrl.Url_CouponsVoucherTemplate)
	public void couponsVoucherTemplate(HttpServletResponse response) throws IOException {
		ExcelUtil<ImportCouponsVoucherVo> util = new ExcelUtil<>(ImportCouponsVoucherVo.class);
		util.importTemplateExcel(response, "优惠券导入模板");
	}

	//获取代订餐人员导入模板
	@GetMapping(WebApiServiceUrl.URL_OrderReplaceDetail_dataTemplate)
	public void subsidyDataTemplate(HttpServletResponse response) throws IOException {
		ExcelUtil<ForecastDataVo> util = new ExcelUtil<>(ForecastDataVo.class);
		util.importTemplateExcel(response, "代订餐人员");
	}

}